<template>
  <div class="wrapper">
    <swiper :options="swiperOption" v-if="showSwiper">
      <!-- slides -->
      <swiper-slide v-for="item in list" :key="item.id">
          <img class="swiper-img" :src="item.imgUrl"/>
      </swiper-slide>
      <!-- Optional controls -->
      <div class="swiper-pagination" slot="pagination"></div>
    </swiper>
  </div>
</template>

<script>
// import img_url from '@/assets/img/1.jpg'
// import img_url2 from '@/assets/img/2.jpg'
// import img_url3 from '@/assets/img/3.jpg'
export default {
  data() {
    return {
      swiperOption: {
        autoplay: true,
        loop:true, 
        pagination:{
            el:'.swiper-pagination'
        }
        // some swiper options/callbacks
        // 所有的参数同 swiper 官方 api 参数
        // ...
      },
      // swiperList:[{
      //   id:'0001',
      //   imgUrl:img_url
        
      // },{
      //   id:'0002',
      //   imgUrl:require('@/assets/img/2.jpg')
      // },{
      //   id:'0003',
      //   imgUrl:img_url3
      // }
      // ]
    }
  },
  props:{
    list:Array
  },
  computed:{
    showSwiper(){
      return this.list.length
    }
  }
};
</script>

<style lang="stylus" scoped>
    .wrapper >>>.swiper-pagination-bullet-active
        background: #fff
    .wrapper
        overflow:hidden
        width :100
        height :0
        padding-bottom :30.8%
        background: #eee
    .swiper-img
        width:100%
     
</style>
